<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
<title>加密空间</title>
<link rel="shortcut icon" type="image/x-icon" href="../images/cloud_icon.png" />
<meta name="keywords" content="">
<meta name="description" content="">
<meta name="author" content="yinqi">
<link href="../css/bootstrap.min.css" rel="stylesheet">
<link href="../css/materialdesignicons.min.css" rel="stylesheet">
<link rel="stylesheet" href="../js/jconfirm/jquery-confirm.min.css">
<link href="../css/style.min.css" rel="stylesheet">
</head>
  
<body>
<div class="lyear-layout-web">
  <div class="lyear-layout-container">
    <!--左侧导航-->
    <aside class="lyear-layout-sidebar">
      
      <!-- logo -->
      <div id="logo" class="sidebar-header">
        <a href="index.html"><img src="../images/LStorage.png" title="LightYear" alt="LightYear" /></a>
      </div>
      <div class="lyear-layout-sidebar-scroll"> 
        
        <nav class="sidebar-main">
          <ul class="nav nav-drawer">
            <li class="nav-item active"> <a href="index.html"><i class="mdi mdi-home"></i> 我的文件</a> </li>
        	<li class="nav-item active"> <a href="share.html"><i class="mdi mdi-near-me"></i> 共享文件</a> </li>
        	<li class="nav-item active"> <a href="secure.html"><i class="mdi mdi-lock-plus"></i> 加密空间</a> </li>
        	<li class="nav-item active"> <a href="statistics.html"><i class="mdi mdi-chart-areaspline"></i> 统计信息</a> </li>
          	<li class="nav-item nav-item-has-subnav">
          		<a href="javascript:void(0)"><i class="mdi mdi-format-align-justify"></i> 后台管理</a>
          		<ul class="nav nav-subnav">
          			<li> <a href="account_manage.html">账号管理</a> </li>
          			<li> <a href="admin_statistics.html">流量统计</a> </li>
          			<li> <a href="admin_log.html">日志信息</a> </li>
          		</ul>
          	</li>
          </ul>
        </nav>
        
      </div>
      
    </aside>
    <!--End 左侧导航-->
    
    <!--头部信息-->
    <header class="lyear-layout-header">
      
      <nav class="navbar navbar-default">
        <div class="topbar">
          
          <div class="topbar-left">
            <div class="lyear-aside-toggler">
              <span class="lyear-toggler-bar"></span>
              <span class="lyear-toggler-bar"></span>
              <span class="lyear-toggler-bar"></span>
            </div>
            <span class="navbar-page-title"> 加密空间 </span>
          </div>
          
          <ul class="topbar-right">
			  <!-- 个人信息 -->
            <li class="dropdown dropdown-profile">
              <a href="javascript:void(0)" data-toggle="dropdown">
                 <img id="showImage" class="img-avatar img-avatar-48 m-r-10"  src="" />
                <span id="showName"> <span class="caret"></span></span>
              </a>
              <ul class="dropdown-menu dropdown-menu-right">
                <li> <a href="person.html"><i class="mdi mdi-account"></i> 个人信息</a> </li>
                <li> <a href="edit_password.html"><i class="mdi mdi-lock-outline"></i> 修改密码</a> </li>
                <li> <a href="chat.html"><i class="mdi mdi-account"></i> 我的好友</a> </li>
                <li class="divider"></li>
                <li> <a href="javascript:void(0)" onclick="logout()"><i class="mdi mdi-logout-variant"></i> 退出登录</a> </li>
              </ul>
            </li>
            <!--切换主题配色-->
		    <li class="dropdown dropdown-skin">
			  <span data-toggle="dropdown" class="icon-palette"><i class="mdi mdi-palette"></i></span>
			  <ul class="dropdown-menu dropdown-menu-right" data-stopPropagation="true">
                <li class="drop-title"><p>主题</p></li>
                <li class="drop-skin-li clearfix">
                  <span class="inverse">
                    <input type="radio" name="site_theme" value="default" id="site_theme_1" checked>
                    <label for="site_theme_1"></label>
                  </span>
                  <span>
                    <input type="radio" name="site_theme" value="dark" id="site_theme_2">
                    <label for="site_theme_2"></label>
                  </span>
                  <span>
                    <input type="radio" name="site_theme" value="translucent" id="site_theme_3">
                    <label for="site_theme_3"></label>
                  </span>
                </li>
			    <li class="drop-title"><p>LOGO</p></li>
				<li class="drop-skin-li clearfix">
                  <span class="inverse">
                    <input type="radio" name="logo_bg" value="default" id="logo_bg_1" checked>
                    <label for="logo_bg_1"></label>
                  </span>
                  <span>
                    <input type="radio" name="logo_bg" value="color_2" id="logo_bg_2">
                    <label for="logo_bg_2"></label>
                  </span>
                  <span>
                    <input type="radio" name="logo_bg" value="color_3" id="logo_bg_3">
                    <label for="logo_bg_3"></label>
                  </span>
                  <span>
                    <input type="radio" name="logo_bg" value="color_4" id="logo_bg_4">
                    <label for="logo_bg_4"></label>
                  </span>
                  <span>
                    <input type="radio" name="logo_bg" value="color_5" id="logo_bg_5">
                    <label for="logo_bg_5"></label>
                  </span>
                  <span>
                    <input type="radio" name="logo_bg" value="color_6" id="logo_bg_6">
                    <label for="logo_bg_6"></label>
                  </span>
                  <span>
                    <input type="radio" name="logo_bg" value="color_7" id="logo_bg_7">
                    <label for="logo_bg_7"></label>
                  </span>
                  <span>
                    <input type="radio" name="logo_bg" value="color_8" id="logo_bg_8">
                    <label for="logo_bg_8"></label>
                  </span>
				</li>
				<li class="drop-title"><p>头部</p></li>
				<li class="drop-skin-li clearfix">
                  <span class="inverse">
                    <input type="radio" name="header_bg" value="default" id="header_bg_1" checked>
                    <label for="header_bg_1"></label>                      
                  </span>                                                    
                  <span>                                                     
                    <input type="radio" name="header_bg" value="color_2" id="header_bg_2">
                    <label for="header_bg_2"></label>                      
                  </span>                                                    
                  <span>                                                     
                    <input type="radio" name="header_bg" value="color_3" id="header_bg_3">
                    <label for="header_bg_3"></label>
                  </span>
                  <span>
                    <input type="radio" name="header_bg" value="color_4" id="header_bg_4">
                    <label for="header_bg_4"></label>                      
                  </span>                                                    
                  <span>                                                     
                    <input type="radio" name="header_bg" value="color_5" id="header_bg_5">
                    <label for="header_bg_5"></label>                      
                  </span>                                                    
                  <span>                                                     
                    <input type="radio" name="header_bg" value="color_6" id="header_bg_6">
                    <label for="header_bg_6"></label>                      
                  </span>                                                    
                  <span>                                                     
                    <input type="radio" name="header_bg" value="color_7" id="header_bg_7">
                    <label for="header_bg_7"></label>
                  </span>
                  <span>
                    <input type="radio" name="header_bg" value="color_8" id="header_bg_8">
                    <label for="header_bg_8"></label>
                  </span>
				</li>
				<li class="drop-title"><p>侧边栏</p></li>
				<li class="drop-skin-li clearfix">
                  <span class="inverse">
                    <input type="radio" name="sidebar_bg" value="default" id="sidebar_bg_1" checked>
                    <label for="sidebar_bg_1"></label>
                  </span>
                  <span>
                    <input type="radio" name="sidebar_bg" value="color_2" id="sidebar_bg_2">
                    <label for="sidebar_bg_2"></label>
                  </span>
                  <span>
                    <input type="radio" name="sidebar_bg" value="color_3" id="sidebar_bg_3">
                    <label for="sidebar_bg_3"></label>
                  </span>
                  <span>
                    <input type="radio" name="sidebar_bg" value="color_4" id="sidebar_bg_4">
                    <label for="sidebar_bg_4"></label>
                  </span>
                  <span>
                    <input type="radio" name="sidebar_bg" value="color_5" id="sidebar_bg_5">
                    <label for="sidebar_bg_5"></label>
                  </span>
                  <span>
                    <input type="radio" name="sidebar_bg" value="color_6" id="sidebar_bg_6">
                    <label for="sidebar_bg_6"></label>
                  </span>
                  <span>
                    <input type="radio" name="sidebar_bg" value="color_7" id="sidebar_bg_7">
                    <label for="sidebar_bg_7"></label>
                  </span>
                  <span>
                    <input type="radio" name="sidebar_bg" value="color_8" id="sidebar_bg_8">
                    <label for="sidebar_bg_8"></label>
                  </span>
				</li>
			  </ul>
			</li>
            <!--切换主题配色-->
          </ul>
          
        </div>
      </nav>
      
    </header>
    <!--End 头部信息-->
    
    <!--页面主要内容-->
    <main class="lyear-layout-content">
      
      <div class="container-fluid">
        
        <div class="row">
          <div class="col-lg-12">
            <div class="card">
              <div class="card-toolbar clearfix">
                <form class="pull-right search-bar" method="get" action="#!" role="form">
                  <div class="input-group">
                    <!-- <div class="input-group-btn">
                      <input type="hidden" name="search_field" id="search-field" value="title">
                      <button class="btn btn-default dropdown-toggle" id="search-btn" data-toggle="dropdown" type="button" aria-haspopup="true" aria-expanded="false">
                      搜索<span class="caret"></span>
                      </button>
                     <ul class="dropdown-menu">
                        <li> <a tabindex="-1" href="javascript:void(0)" data-field="title">标题</a> </li>
                        <li> <a tabindex="-1" href="javascript:void(0)" data-field="cat_name">栏目</a> </li>
                      </ul>
                    </div> -->
                    <input type="text" class="form-control" value="" name="keyword" placeholder="请输入搜索内容">
                  </div>
                </form>
                <div class="toolbar-btn-action">
                  <a class="btn btn-dark m-r-5" onclick="lastPage()"><i class="mdi mdi-arrow-left-drop-circle"></i> 返回</a>
                  <a class="btn btn-primary m-r-5" data-toggle="modal" data-target="#gridSystemModal"><i class="mdi mdi-arrow-collapse-up"></i> 上传</a>
                  <a class="btn btn-success m-r-5" onclick="downloadFiles()"><i class="mdi mdi-arrow-collapse-down"></i> 下载</a>
                  <a class="btn btn-info m-r-5 createFolder"><i class="mdi mdi-playlist-plus"></i> 新建文件夹</a>
                  <a class="btn btn-warning m-r-5" onclick="shareFiles()"><i class="mdi mdi-launch"></i> 分享</a>
                  <a class="btn btn-danger m-r-5" onclick="delFiles()"><i class="mdi mdi-window-close"></i> 删除</a>
                </div>
				<!-- 上传文件弹出层-->
				<div class="modal fade" tabindex="-1" role="dialog" aria-labelledby="gridSystemModalLabel" id="gridSystemModal">
				  <div class="modal-dialog" role="document">
				    <div class="modal-content">
				      <div class="modal-header">
				        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
				        <h4 class="modal-title" id="gridSystemModalLabel">文件上传</h4>
				      </div>
				      <div class="modal-body">
				       <div class="col-xs-12">
						   <form class="btn btn-default" id="uploadFile" enctype="multipart/form-data" method="POST" action="return false">
							   <input type="file" id="file" name="file" multiple>
						   </from>
				       </div>
				      </div>
				      <div class="modal-footer">
				        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
				        <button type="button" class="btn btn-primary" onclick="upload()">上传</button>
				      </div>
				    </div>
				  </div>
				</div>
				<!-- End 上传文件弹出层-->
              </div>
              <div class="card-body">
                
                <div class="table-responsive">
                  <table class="table table-bordered">
                    <thead>
                      <tr>
                        <th>
                          <label class="lyear-checkbox checkbox-primary">
                            <input type="checkbox" id="check-all"><span></span>
                          </label>
                        </th>
                        <th>文件名</th>
                        <th>文件大小</th>
                        <th>上传日期</th>
                        <th>操作</th>
                      </tr>
                    </thead>
                    <tbody id="showDocuments">
                      <!-- <tr>
                        <td>
                          <label class="lyear-checkbox checkbox-primary">
                            <input type="checkbox" name="ids[]" value="1"><span></span>
                          </label>
                        </td>
                        <td><img src="images/icon/doc.png" width="20px">  第01章 天涯思君不可忘</td>
                        <td>300KB</td>
                        <td>2020-02-08 12:20:47</td>
                        <td>
                          <div class="btn-group">
                            <a class="btn btn-xs btn-default" href="#!" title="编辑" data-toggle="tooltip"><i class="mdi mdi-pencil"></i></a>
                            <a class="btn btn-xs btn-default" href="#!" title="删除" data-toggle="tooltip"><i class="mdi mdi-window-close"></i></a>
                          </div>
                        </td>
                      </tr> -->
                    </tbody>
                  </table>
                </div>
				<!-- 分页 -->
                <ul class="pagination" id="pages">
                  <!-- <li class="disabled"><span>«</span></li>
                  <li class="active"><span>1</span></li>
                  <li><a href="#1">2</a></li>
                  <li><a href="#1">3</a></li>
                  <li><a href="#1">4</a></li>
                  <li><a href="#1">5</a></li>
                  <li><a href="#1">6</a></li>
                  <li><a href="#1">7</a></li>
                  <li><a href="#1">8</a></li>
                  <li class="disabled"><span>...</span></li>
                  <li><a href="#!">14452</a></li>
                  <li><a href="#!">14453</a></li>
                  <li><a href="#!">»</a></li> -->
                </ul>
				<!-- END 分页 -->
              </div>
            </div>
          </div>
          
        </div>
        
      </div>
      
    </main>
    <!--End 页面主要内容-->
  </div>
</div>

<script type="text/javascript" src="../js/jquery.min.js"></script>
<script type="text/javascript" src="../js/bootstrap.min.js"></script>
<script type="text/javascript" src="../js/perfect-scrollbar.min.js"></script>
<script src="../js/jconfirm/jquery-confirm.min.js"></script>
<script type="text/javascript" src="../js/JavaScript_util.js"></script>
<script type="text/javascript" src="../js/main.min.js"></script>
<script type="text/javascript">
	sessionStorage.setItem("nowPath",sessionStorage.getItem("account") + ",secure");
	showMyInfo();
	var oldId = 1;
	isWin();
	function isWin(){
		var secureP = sessionStorage.getItem("secureP");
		if(secureP == null || secureP == ""){
			$.confirm({
		        title: '提示',
		        content: '' +
		        '<form action="" class="formName">' +
		        '<div class="form-group">' +
		        '<input type="password" placeholder="请输入密码" class="name form-control" required />' +
		        '</div>' +
		        '</form>',
		        buttons: {
		            formSubmit: {
		                text: '提交',
		                btnClass: 'btn-blue',
		                action: function () {
		                    var password = this.$content.find('.name').val();
		                    if(!password){
		                        $.alert('密码不能为空');
		                        return false;
		                    }
		                    var flag = checkSecure(password);
		                    var secureP = sessionStorage.getItem("secureP");
		                    if(secureP == 1){
		                    	showDocuments(1);
			                    getPages();
		                    }else{
		                    	alert("密码错误！");
		                    	window.parent.location.reload();
		                    }
		                    
		                }
		            },
		            cancel: {
		                text: '取消',
		                action: function () {
		                    skipPage("admin_pages/index.html");
		                }
		            },
		        },
		        onContentReady: function () {
		            var jc = this;
		            this.$content.find('form').on('submit', function (e) {
		                e.preventDefault();
		                jc.$$formSubmit.trigger('click');
		            });
		        }
		    });
		}else{
			showDocuments(1);
            getPages();
		}
	}
	//校验加密空间密码
	function checkSecure(password){
		$.ajax({
			type : "POST",//方法类型
			async : false,
			dataType : "json",//预期服务器返回的数据类型
			url :  getURL() + "account/checkSecure",
			data : {
				account : sessionStorage.getItem("account"),
				password : password
			},
			success : function(result) {
				if(result){
					sessionStorage.setItem("secureP",1);
				}else{
					sessionStorage.setItem("secureP",0);
				}
				
			},
			error : function(e){
				alert("网络错误");
			}
		});
	}
	
	//显示分页
	function getPages(){
		$.ajax({
			type : "POST",//方法类型
			dataType : "json",//预期服务器返回的数据类型
			url :  getURL() + "secureFile/getDocument",
			data : {
				path : sessionStorage.getItem("nowPath"),
				index : 1
			},
			success : function(result) {
				var pages = result.pages;
				if(pages != 0){
					oldId = 1;
					var str = "";
					str += `<li onclick="changePages(1)" style="cursor:pointer;"><span>«</span></li>`;
					str += ` 
						<li class="active" id="1" onclick="changePages(1)" style="cursor:pointer;"><span>1</span></li>
					`;
					for(var i = 1; i < pages; i++){
						str += ` 
							<li id="${i+1}" style="cursor:pointer;"><a onclick="changePages(${i+1})">${i+1}</a></li>
						`;
					}
					str += ` <li><a onclick="changePages(${pages})" style="cursor:pointer;">»</a></li>`;
					document.getElementById('pages').innerHTML = str;
				}
			},
			error : function(e){
				
			}
		});
	}
	//分页切换
	function changePages(index){
		$('#'+oldId).removeClass('active');
		$('#'+index).addClass('active');
		oldId = index;
		showDocuments(index);
	}
	//展示出文件
	function showDocuments(index){
		$.ajax({
			type : "POST",//方法类型
			dataType : "json",//预期服务器返回的数据类型
			url :  getURL() + "secureFile/getDocument",
			data : {
				path : sessionStorage.getItem("nowPath"),
				index : index
			},
			success : function(result) {
				var ds = result.documents;
				var str = "";
				for(var i = 0; i < ds.length; i++){
					var img = getFileIcon(ds[i].folderName,ds[i].size);
					var size = "";
					if(ds[i].size == -1){
						size += "--";
					}else{
						size += changeUnit(ds[i].size);
					}
					str += `
						<tr>
	                        <td>
	                          <label class="lyear-checkbox checkbox-primary">
	                            <input type="checkbox" name="choose" value="${ds[i].folderName}" id="${ds[i].id}"><span></span>
	                          </label>
	                        </td>
	                        <td onclick="nextPage('${ds[i].folderName}','${ds[i].size}')" style="cursor:pointer;">
	                        	<img src="../icon/${img}" width="20px"> ${ds[i].folderName}
	                        </td>
	                        <td>${size}</td>
	                        <td>${ds[i].createDate}</td>
	                        <td>
	                          <div class="btn-group">
	                            <a class="btn btn-xs btn-default" onclick="modifiyName('${ds[i].folderName}',${ds[i].id})" title="编辑" data-toggle="tooltip"><i class="mdi mdi-pencil"></i></a>
	                            <a class="btn btn-xs btn-default" onclick="delFile('${ds[i].folderName}',${ds[i].id})" title="删除" data-toggle="tooltip"><i class="mdi mdi-window-close"></i></a>
	                          </div>
	                        </td>
	                     </tr>
					`;
				}
				if(ds.length == 0){
					str = `<tr><td colspan="5" style="text-align: center;">当前目录未上传文件！</td></tr>`;
				}
				document.getElementById('showDocuments').innerHTML = str;
			},
			error : function(e){
				
			}
		});
	}
	//下载按钮
	function downloadFiles(){
		var res = getChooseV();
		if(res == 0){
			alert("请选择文件或文件夹！");
			return;
		}else{
			var str = "";
			for(var i=0;i<res.length;i++){
				str += res[i] + ",";
			}
			str = str.substring(0,str.length - 1);
			window.location.href= getURL() + "downloadFiles?fileNames="+str+"&path="+sessionStorage.getItem("nowPath");
		}
	}
	//删除按钮
	function delFiles(){
		var ids = getChooseI();
		var fileNames = getChooseV();
		var res = ids.length;
		if(res == 0){
			alert("请选择文件或文件夹！");
			return;
		}else{
			var flag = isDelete();
			if(!flag){
				return;
			}
			var str1 = "";
			var str2 = "";
			for(var i=0;i<res;i++){
				str1 += ids[i] + ",";
				str2 += fileNames[i] + ",";
			}
			str1 = str1.substring(0,str1.length - 1);
			str2 = str2.substring(0,str2.length - 1);
			$.ajax({
				type : "POST",//方法类型
				dataType : "json",//预期服务器返回的数据类型
				url :  getURL() + "secureFile/deleteDocument",
				data : {
					path : sessionStorage.getItem("nowPath"),
					fileNames : str2,
					ids : str1
				},
				success : function(result) {
					if(result.flag){
						alert("删除成功!");
					}else{
						alert("删除失败！");
					}
					showDocuments(1);
				},
				error : function(e){
					
				}
			});
		}
	}
	//获取选中选项值
	function getChooseV() {
        //首先我们要得到多选框中有一些什么样的值
        var date = document.getElementsByName("choose");
        //然后我们去得到这个多选框的长度
        var thisLength = date.length;
        //使用字符串数组，用于存放选择好了的数据
        var res = new Array();
        for(var i = 0;i < thisLength;i++) {
            if (date[i].checked == true) {
            	res.push(date[i].value);
            }
        }
        return res;
    }
	//获取选中选项ID
	function getChooseI() {
        //首先我们要得到多选框中有一些什么样的值
        var date = document.getElementsByName("choose");
        //然后我们去得到这个多选框的长度
        var thisLength = date.length;
        //使用字符串数组，用于存放选择好了的数据
        var res = new Array();
        for(var i = 0;i < thisLength;i++) {
            if (date[i].checked == true) {
            	res.push(date[i].id);
            }
        }
        return res;
    }
	//分享按钮
	function shareFiles(){
		//判断是否选择文件或文件夹
		var res = getChooseV();
		var len = res.length;
		if(len == 0){
			alert("请选择文件或文件夹！");
			return;
		}
		//是否需要加密文件
		var lock = 0;//默认加密
		var lockPassword = "";
		var isLock = confirm("是否加密分享文件?");
		if(isLock){
			var lockPassword = prompt("请输入加密密码","");
			if(!lockPassword){
				alert("密码不能为空!");
				return;
			}
		}else{
			lock = 1;
		}
		
		
		var str = "";
		for(var i=0;i<len;i++){
			str += res[i] + ",";
		}
		str = str.substring(0,str.length - 1);
		$.ajax({
			type : "POST",//方法类型
			dataType : "json",//预期服务器返回的数据类型
			url :  getURL() + "share/addShare",
			data : {
				fileNames : str,
				path : sessionStorage.getItem("nowPath"),
				lock : lock,
				lockPassword : lockPassword,
				userName : sessionStorage.getItem("userName")
			},
			success : function(result) {
				if(result.flag){
					alert("分享成功!");
				}else if(result.type == 1){
					alert("文件：" + result.fileName + "  已被分享！");
				}
				showShareDocuments();
			},
			error : function(e){
				
			}
		});
	}
	//下一级
	function nextPage(name,size){
		if(size == -1){
			var str = sessionStorage.getItem("nowPath");
			str = str + "," + name;
			sessionStorage.setItem("nowPath",str);
			showDocuments(1);
			getPages();
		}else{
			window.location.href= getURL() + "downloadFile?fileName="+name+"&path="+sessionStorage.getItem("nowPath");
		}
	}
	//上一级
	function lastPage(){
		var str = sessionStorage.getItem("nowPath");
		if(str.indexOf(",") != -1){
			str = str.substring(0,str.lastIndexOf(","));
			sessionStorage.setItem("nowPath",str);
			showDocuments(1);
			getPages();
		}else{
			alert("没有更多了...");
		}
	}
	//新建文件夹
	function newFolder(){
		var fileName = $('#newFolder').val();
		if(fileName == ''){
			alert("名称不能为空！");
		}else{
			$.ajax({
				type : "POST",//方法类型
				dataType : "json",//预期服务器返回的数据类型
				url :  getURL() + "secureFile/createFolder",
				data : {
					path : sessionStorage.getItem("nowPath"),
					fileName : fileName
				},
				success : function(result) {
					if(result.flag){
						alert("创建成功!");
						showDocuments(1);
					}else if(result.type == 1){
						alert("名称已存在！");
					}
				},
				error : function(e){
					
				}
			});
		}
	}
	$('.createFolder').on('click', function () {
	    $.confirm({
	        title: '创建文件夹',
	        content: '' +
	        '<form action="" class="formName">' +
	        '<div class="form-group">' +
	        '<input type="text" placeholder="请输入文件夹名称" class="name form-control" required />' +
	        '</div>' +
	        '</form>',
	        buttons: {
	            formSubmit: {
	                text: '提交',
	                btnClass: 'btn-blue',
	                action: function () {
	                    var fileName = this.$content.find('.name').val();
	                    if(!fileName){
	                        $.alert('请您输入文件夹名称');
	                        return false;
	                    }
	                    $.ajax({
	        				type : "POST",//方法类型
	        				dataType : "json",//预期服务器返回的数据类型
	        				url :  getURL() + "secureFile/createFolder",
	        				data : {
	        					path : sessionStorage.getItem("nowPath"),
	        					fileName : fileName
	        				},
	        				success : function(result) {
	        					if(result.flag){
	        						alert("创建成功!");
	        						showDocuments(1);
	        					}else if(result.type == 1){
	        						alert("名称已存在！");
	        					}
	        				},
	        				error : function(e){
	        					
	        				}
	        			});
	                }
	            },
	            cancel: {
	                text: '取消'
	            },
	        },
	        onContentReady: function () {
	            var jc = this;
	            this.$content.find('form').on('submit', function (e) {
	                e.preventDefault();
	                jc.$$formSubmit.trigger('click');
	            });
	        }
	    });
	});
	//修改文件名
	function modifiyName(name,id){
		$.confirm({
	        title: '修改文件名',
	        content: '' +
	        '<form action="" class="formName">' +
	        '<div class="form-group">' +
	        '<input type="text" placeholder="'+name+'" class="name form-control" required />' +
	        '</div>' +
	        '</form>',
	        buttons: {
	            formSubmit: {
	                text: '提交',
	                btnClass: 'btn-blue',
	                action: function () {
	                    var fileName = this.$content.find('.name').val();
	                    if(!fileName){
	                        $.alert('请您输入名称');
	                        return false;
	                    }
	                    $.ajax({
	        				type : "POST",//方法类型
	        				dataType : "json",//预期服务器返回的数据类型
	        				url :  getURL() + "secureFile/modifiyDocument",
	        				data : {
	        					path : sessionStorage.getItem("nowPath"),
	        					fileName : fileName,
	        					id : id
	        				},
	        				success : function(result) {
	        					if(result.flag){
	        						alert("修改成功!");
	        						showDocuments(1);
	        					}else if(result.type == 1){
	        						alert("名称已存在！");
	        					}
	        				},
	        				error : function(e){
	        					
	        				}
	        			});
	                }
	            },
	            cancel: {
	                text: '取消'
	            },
	        },
	        onContentReady: function () {
	            var jc = this;
	            this.$content.find('form').on('submit', function (e) {
	                e.preventDefault();
	                jc.$$formSubmit.trigger('click');
	            });
	        }
	    });
	}
	//删除单个文件
	function delFile(fileName,id){
		$.confirm({
	        title: '操作提示',
	        content: '文件删除后无法恢复，确定要删除文件？',
	        type: 'red',
	        typeAnimated: true,
	        buttons: {
	            tryAgain: {
	                text: '确认',
	                btnClass: 'btn-red',
	                action: function(){
	                	$.ajax({
	        				type : "POST",//方法类型
	        				dataType : "json",//预期服务器返回的数据类型
	        				url :  getURL() + "secureFile/deleteDocument",
	        				data : {
	        					path : sessionStorage.getItem("nowPath"),
	        					fileNames : fileName,
	        					ids : id
	        				},
	        				success : function(result) {
	        					if(result.flag){
	        						alert("删除成功!");
	        					}else{
	        						alert("删除失败！");
	        					}
	        					showDocuments(1);
	        				},
	        				error : function(e){
	        					
	        				}
	        			});
	                }
	            },
	            close: {
	                text: '取消'
	            }
	        }
	    });
	}
	//文件上传
	function upload() {
		var data = new FormData($("#uploadFile")[0]);
		$.ajax({
			url : getURL() + "uploadSecureFile?path="+sessionStorage.getItem("nowPath")+"&account="+sessionStorage.getItem("account"),
		  	data : data,
		  	cache : false,//true使用缓存 。 false不使用缓存
		  	async : true,//true异步加载。 false同步加载
		 	contentType : false, //这两句需要添加上，否则会跳转页面
		 	processData : false,
			type : "POST",
			dataType : 'text',//json/xml/html
			success : function (result){
				if(result.flag){
					alert("上传成功");
				}
				window.parent.location.reload();
			},
			error : function(e){
			}
		});
	}
</script>
</body>
</html>